{% extends 'snippet/layout.html' %}
{% load forum_extras %}

{% block main %}
    <div class="topics container-box user-topics">
        <div class="ui-header">
            <span class="bread-nav">F2E › {{ user_info.username }} › 收藏的主题列表</span>
        </div>

        <div class="ui-content">
            {% for favorite in favorites %}
                <div class="topic-item">
                    <a href="/u/{{ favorite.involved_topic.author.username }}/">
                        <img src="/static/avatar/m_{% if favorite.involved_topic.author.avatar %}{{ favorite.involved_topic.author.avatar }}{% else %}default.png{% endif %}" alt="" class="avatar" />
                    </a>
                    <div class="main">
                        <h3 class="title">
                            <a href="/t/{{ favorite.involved_topic.id }}/">{{ favorite.involved_topic.title }}</a>
                        </h3>
                        <div class="meta">
                            <span class="node"><a href="/node/{{ favorite.involved_topic.node.slug }}/">{{ favorite.involved_topic.node.name }}</a></span> •
                            <span class="username">
                                <a href="/u/{% if favorite.involved_topic.author.username %}{{ favorite.involved_topic.author.username }}{% else %}{{ favorite.involved_topic.author.id }}{% endif %}/">{{ favorite.involved_topic.author.username }}</a>
                            </span> •
                            {% if favorite.involved_topic.last_replied_time %}
                                <span class="last-touched">{{ favorite.involved_topic.last_touched|pretty_date }}</span> •
                                <span class="last-reply-username">最后回复来自
                                    <a href="/u/{% if favorite.involved_topic.last_replied_by.username %}{{ favorite.involved_topic.last_replied_by.username }}{% else %}{{ favorite.involved_topic.last_replied_by.id }}{% endif %}/">
                                        <strong>{{ favorite.involved_topic.last_replied_by.username }}</strong>
                                    </a>
                                </span>
                            {% else %}
                                <span class="last-touched">{{ favorite.involved_topic.last_touched|pretty_date }}</span>
                            {% endif %}
                        </div>
                    </div>
                    {% if favorite.involved_topic.reply_count %}
                        <div class="count">
                            <a href="/t/{{ favorite.involved_topic.id }}/#reply{% if favorite.involved_topic.reply_count %}{{ favorite.involved_topic.reply_count }}{% else %}0{% endif %}">{% if favorite.involved_topic.reply_count %}{{ favorite.involved_topic.reply_count }}{% else %}0{% endif %}</a>
                        </div>
                    {% endif %}
                </div>
            {% endfor %}

            {% ifequal favorite_page.total 0 %}
                <div class="pl10 pr10">
                    <div class="alert mt20 no-favorites">
                        该用户暂时还没有收藏过主题。
                    </div>
                </div>
            {% endifequal %}
        </div>

        <div class="ui-footer">
        {% if favorite_page.pages > 1 %}
            <div class="pagination">
                {% pagination favorite_page request.get_full_path %}
            </div>
        {% endif %}
        </div>
    </div>
{% endblock %}

{% block sidebar %}
    <div class="usercard container-box">
        <div class="ui-header">
            <a href="/u/{{ user_info.username }}/">
                <img src="/static/avatar/m_{% if user_info.avatar %}{{ user_info.avatar }}{% else %}default.png{% endif %}?t={% gen_random %}" alt="" class="avatar" />
            </a>
            <div class="username">{{ user_info.username }}</div>
            <div class="website">{% if user_info.website %}{{ user_info.website }}{% endif %}</div>
        </div>
        <div class="ui-content">
            <div class="status status-topic">
                <strong><a href="/u/{{ user_info.username }}/topics/">{{ counter.topics }}</a></strong> 主题
            </div>
            <div class="status status-reply">
                <strong><a href="/u/{{ user_info.username }}/replies/">{{ counter.replies }}</a></strong> 回复
            </div>
            <div class="status status-favorite">
                <strong><a href="/u/{{ user_info.username }}/favorites/">{{ counter.favorites }}</a></strong> 收藏
            </div>
            <div class="status status-reputation">
                <strong>{% if user_info.reputation %}{{ user_info.reputation }}{% else %}0{% endif %}</strong> 威望
            </div>
        </div>
    </div>
</div>
{% endblock %}
